package top.tagao.m03_beHavioralPatterns.b_11_Iterator.iterators;

import top.tagao.m03_beHavioralPatterns.b_11_Iterator.Department;

import java.util.Iterator;
import java.util.List;

/**
 * @author Viktor_Liu
 * @Date 2022/8/14 23:17
 */
public class InfoCollegeIterator implements Iterator {
    // 信息工程学院是以List方式存放系
    List<Department> departmentList;

    //索引
    int index = -1;


    public InfoCollegeIterator(List<Department> departmentList) {
        this.departmentList = departmentList;
    }

    @Override
    public boolean hasNext() {
        if(index >= departmentList.size() - 1) {
            return false;
        } else {
            index += 1;
            return true;
        }
    }

    @Override
    public Object next() {
        return departmentList.get(index);
    }

    @Override
    public void remove() {

    }
}
